# coding:utf-8
__author__ = 'Miller'
__date__ = '2017/3/20 13:46 '
import xadmin
from .models import UserAsk, CourseComment, UserFavoite, UserMessage, UserCourse


# Create your models here.
class UserAskAdmin(object):
    search_fields = ['name', 'mobile', 'course_name', 'add_time']
    list_filter = ['name', 'mobile', 'course_name', 'add_time']
    list_display = ['name', 'mobile', 'course_name', 'add_time']


class CourseCommentAdmin(object):
    search_fields = ['user', 'course', 'comment', 'add_time']
    list_filter = ['user__nick_name', 'course__name', 'comment', 'add_time']
    list_display = ['user', 'course', 'comment', 'add_time']


class UserFavoiteAdmin(object):
    search_fields = ['user', 'fav_id', 'comment', 'add_time', 'fav_type']
    list_filter = ['user__nick_name', 'fav_id', 'comment', 'add_time', 'fav_type']
    list_display = ['user', 'fav_id', 'comment', 'add_time', 'fav_type']


class UserMessageAdmin(object):
    search_fields = ['user', 'message', 'hasread', 'add_time']
    list_filter = ['user', 'message', 'hasread', 'add_time']
    list_display = ['user', 'message', 'hasread', 'add_time']


class UserCourseAdmin(object):
    search_fields = ['user', 'course', 'add_time']
    list_filter = ['user__nick_name', 'course__name', 'add_time']
    list_display = ['user', 'course', 'add_time']


# 如果使用外键,只需要user__nick_name,就可以指定对其nick_name字段进行过滤

xadmin.site.register(UserAsk, UserAskAdmin)
xadmin.site.register(CourseComment, CourseCommentAdmin)
xadmin.site.register(UserFavoite, UserFavoiteAdmin)
xadmin.site.register(UserMessage, UserMessageAdmin)
xadmin.site.register(UserCourse, UserCourseAdmin)

